package model;

import java.util.ArrayList;

import controller.Calculator;

/**
 * @author Alexander Müller
 * 
 */
public class HostAddress {

	private final IPAddress address;
	private String name;
	private ArrayList<Subnet> subnet = new ArrayList<Subnet>();
	private final ArrayList<Integer> spaces = new ArrayList<Integer>();
	private int freeRange;
	private final Calculator calc = Calculator.getInstance();

	public HostAddress(IPAddress address) {
		this.address = address;
		name = this.address.getAddress();
		int ipClass = calc.calculateIpClass(address.getAddressBits(0)
				.getBitValue());
		freeRange = calc.calculatePossibleHosts(ipClass, address) + 1;
	}

	public HostAddress(IPAddress adress, String name) {
		this.address = adress;
		this.name = name;
		int ipClass = calc.calculateIpClass(address.getAddressBits(0)
				.getBitValue());
		freeRange = calc.calculatePossibleHosts(ipClass, address) + 1;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}


	public IPAddress getHostAddress() {
		return address;
	}

	public ArrayList<Subnet> getSubnetList() {
		return subnet;
	}

	public int getRange() {
		return freeRange;
	}

	public void setRange(int range) {
		this.freeRange = range;
	}

	public void setSubnet(ArrayList<Subnet> subnet) {
		this.subnet = subnet;
		
	}

	public ArrayList<Integer> getSpaces() {
		return spaces;
	}
}
